<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Web app lifecycle</title>
    <style>
        #first {color: green;}
        #second { color: red;}
    </style>
</head>
<body>
    <ul id="first"> </ul>

    <script>
        function addMessage(element, message) {
            var messageElement = document.createElement("li");
            messageElement.textContent = message;
            element.append(messageElement);
        }
        var first = document.getElementById("first");
        addMessage(first, "Page loading");
    </script>

    <ul id="second"></ul>
    <script>
        document.body.addEventListener("mousemove", function () {
            var second = document.getElementById("second");
            addMessage(second, "Event: mousemove");
        });

        document.body.addEventListener("click", function () {
            var second = document.getElementById("second");
            addMessage(second, "Event: click");
        })
    </script>
</body>
</html>